using System;
using System.Data;
using System.Data.OleDb;
using System.Collections;
using System.Configuration;
using PCSComUtils.DataAccess;
using PCSComUtils.PCSExc;
using PCSComUtils.Common;
using System.Runtime.InteropServices;

namespace PCSComProduct.Costing.DS
{
	[Guid("477411FC-6D89-4b01-8ED8-8AFBBFA71E7E")]
	public class ITM_CostDescriptionDS 
	{
		public ITM_CostDescriptionDS()
		{
		}
		private const string THIS = "PCSComProduct.Costing.DS.ITM_CostDescriptionDS";

	
		//**************************************************************************              
		///    <Description>
		///       This method uses to add data to ITM_CostDescription
		///    </Description>
		///    <Inputs>
		///        ITM_CostDescriptionVO       
		///    </Inputs>
		///    <Outputs>
		///       newly inserted primarkey value
		///    </Outputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <Authors>
		///       HungLa
		///    </Authors>
		///    <History>
		///       Wednesday, March 16, 2005
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************


		public void Add(object pobjObjectVO)
		{
			const string METHOD_NAME = THIS + ".Add()";
			 
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS =null;
			try
			{
				ITM_CostDescriptionVO objObject = (ITM_CostDescriptionVO) pobjObjectVO;
				string strSql = String.Empty;
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand("", oconPCS);
				
				strSql=	"INSERT INTO ITM_CostDescription("
				+ ITM_CostDescriptionTable.COSTDESC01_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC02_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC03_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC04_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC05_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC06_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC07_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC08_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC09_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC10_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC11_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC12_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC13_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC14_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC15_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC16_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC17_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC18_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC19_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC20_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC21_FLD + ","
				+ ITM_CostDescriptionTable.MACHRUNHRSDESC_FLD + ","
				+ ITM_CostDescriptionTable.MACHSETUPHRSDESC_FLD + ","
				+ ITM_CostDescriptionTable.LABORRUNHRSDESC_FLD + ","
				+ ITM_CostDescriptionTable.LABORSETUPHRSDESC_FLD + ","
				+ ITM_CostDescriptionTable.CCNID_FLD + ")"
				+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC01_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC01_FLD].Value = objObject.CostDesc01;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC02_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC02_FLD].Value = objObject.CostDesc02;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC03_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC03_FLD].Value = objObject.CostDesc03;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC04_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC04_FLD].Value = objObject.CostDesc04;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC05_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC05_FLD].Value = objObject.CostDesc05;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC06_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC06_FLD].Value = objObject.CostDesc06;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC07_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC07_FLD].Value = objObject.CostDesc07;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC08_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC08_FLD].Value = objObject.CostDesc08;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC09_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC09_FLD].Value = objObject.CostDesc09;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC10_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC10_FLD].Value = objObject.CostDesc10;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC11_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC11_FLD].Value = objObject.CostDesc11;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC12_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC12_FLD].Value = objObject.CostDesc12;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC13_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC13_FLD].Value = objObject.CostDesc13;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC14_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC14_FLD].Value = objObject.CostDesc14;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC15_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC15_FLD].Value = objObject.CostDesc15;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC16_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC16_FLD].Value = objObject.CostDesc16;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC17_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC17_FLD].Value = objObject.CostDesc17;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC18_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC18_FLD].Value = objObject.CostDesc18;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC19_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC19_FLD].Value = objObject.CostDesc19;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC20_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC20_FLD].Value = objObject.CostDesc20;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC21_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC21_FLD].Value = objObject.CostDesc21;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.MACHRUNHRSDESC_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.MACHRUNHRSDESC_FLD].Value = objObject.MachRunHrsDesc;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.MACHSETUPHRSDESC_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.MACHSETUPHRSDESC_FLD].Value = objObject.MachSetupHrsDesc;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.LABORRUNHRSDESC_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.LABORRUNHRSDESC_FLD].Value = objObject.LaborRunHrsDesc;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.LABORSETUPHRSDESC_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.LABORSETUPHRSDESC_FLD].Value = objObject.LaborSetupHrsDesc;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.CCNID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.CCNID_FLD].Value = objObject.CCNID;


				
				ocmdPCS.CommandText = strSql;
				ocmdPCS.Connection.Open();
				ocmdPCS.ExecuteNonQuery();	

			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}
	

	

		//**************************************************************************              
		///    <Description>
		///       This method uses to delete data from ITM_CostDescription
		///    </Description>
		///    <Inputs>
		///        ID       
		///    </Inputs>
		///    <Outputs>
		///       void
		///    </Outputs>
		///    <Returns>
		///       
		///    </Returns>
		///    <Authors>
		///       HungLa
		///    </Authors>
		///    <History>
		///       09-Dec-2004
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************

		public void Delete(int pintID)
		{
			const string METHOD_NAME = THIS + ".Delete()";
			string strSql = String.Empty;
			strSql=	"DELETE " + ITM_CostDescriptionTable.TABLE_NAME + " WHERE  " + "CostDescriptionID" + "=" + pintID.ToString();
			OleDbConnection oconPCS=null;
			OleDbCommand ocmdPCS =null;
			try
			{
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);

				ocmdPCS.Connection.Open();
				ocmdPCS.ExecuteNonQuery();	
				ocmdPCS = null;

			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLCASCADE_PREVENT_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.CASCADE_DELETE_PREVENT, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}



			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}
	

	

		//**************************************************************************              
		///    <Description>
		///       This method uses to get data from ITM_CostDescription
		///    </Description>
		///    <Inputs>
		///        ID       
		///    </Inputs>
		///    <Outputs>
		///       ITM_CostDescriptionVO
		///    </Outputs>
		///    <Returns>
		///       ITM_CostDescriptionVO
		///    </Returns>
		///    <Authors>
		///       HungLa
		///    </Authors>
		///    <History>
		///       Wednesday, March 16, 2005
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************

		public object GetObjectVO(int pintID)
		{
			const string METHOD_NAME = THIS + ".GetObjectVO()";
			DataSet dstPCS = new DataSet();
			
			OleDbDataReader odrPCS = null;
			OleDbConnection oconPCS = null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = String.Empty;
				strSql=	"SELECT "
				+ ITM_CostDescriptionTable.COSTDESCRIPTIONID_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC01_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC02_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC03_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC04_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC05_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC06_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC07_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC08_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC09_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC10_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC11_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC12_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC13_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC14_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC15_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC16_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC17_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC18_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC19_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC20_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC21_FLD + ","
				+ ITM_CostDescriptionTable.MACHRUNHRSDESC_FLD + ","
				+ ITM_CostDescriptionTable.MACHSETUPHRSDESC_FLD + ","
				+ ITM_CostDescriptionTable.LABORRUNHRSDESC_FLD + ","
				+ ITM_CostDescriptionTable.LABORSETUPHRSDESC_FLD + ","
				+ ITM_CostDescriptionTable.CCNID_FLD
				+ " FROM " + ITM_CostDescriptionTable.TABLE_NAME
				+" WHERE " + ITM_CostDescriptionTable.COSTDESCRIPTIONID_FLD + "=" + pintID;

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);

				ocmdPCS.Connection.Open();
				odrPCS = ocmdPCS.ExecuteReader();

				ITM_CostDescriptionVO objObject = new ITM_CostDescriptionVO();

				while (odrPCS.Read())
				{ 
				objObject.CostDescriptionID = int.Parse(odrPCS[ITM_CostDescriptionTable.COSTDESCRIPTIONID_FLD].ToString().Trim());
				objObject.CostDesc01 = odrPCS[ITM_CostDescriptionTable.COSTDESC01_FLD].ToString().Trim();
				objObject.CostDesc02 = odrPCS[ITM_CostDescriptionTable.COSTDESC02_FLD].ToString().Trim();
				objObject.CostDesc03 = odrPCS[ITM_CostDescriptionTable.COSTDESC03_FLD].ToString().Trim();
				objObject.CostDesc04 = odrPCS[ITM_CostDescriptionTable.COSTDESC04_FLD].ToString().Trim();
				objObject.CostDesc05 = odrPCS[ITM_CostDescriptionTable.COSTDESC05_FLD].ToString().Trim();
				objObject.CostDesc06 = odrPCS[ITM_CostDescriptionTable.COSTDESC06_FLD].ToString().Trim();
				objObject.CostDesc07 = odrPCS[ITM_CostDescriptionTable.COSTDESC07_FLD].ToString().Trim();
				objObject.CostDesc08 = odrPCS[ITM_CostDescriptionTable.COSTDESC08_FLD].ToString().Trim();
				objObject.CostDesc09 = odrPCS[ITM_CostDescriptionTable.COSTDESC09_FLD].ToString().Trim();
				objObject.CostDesc10 = odrPCS[ITM_CostDescriptionTable.COSTDESC10_FLD].ToString().Trim();
				objObject.CostDesc11 = odrPCS[ITM_CostDescriptionTable.COSTDESC11_FLD].ToString().Trim();
				objObject.CostDesc12 = odrPCS[ITM_CostDescriptionTable.COSTDESC12_FLD].ToString().Trim();
				objObject.CostDesc13 = odrPCS[ITM_CostDescriptionTable.COSTDESC13_FLD].ToString().Trim();
				objObject.CostDesc14 = odrPCS[ITM_CostDescriptionTable.COSTDESC14_FLD].ToString().Trim();
				objObject.CostDesc15 = odrPCS[ITM_CostDescriptionTable.COSTDESC15_FLD].ToString().Trim();
				objObject.CostDesc16 = odrPCS[ITM_CostDescriptionTable.COSTDESC16_FLD].ToString().Trim();
				objObject.CostDesc17 = odrPCS[ITM_CostDescriptionTable.COSTDESC17_FLD].ToString().Trim();
				objObject.CostDesc18 = odrPCS[ITM_CostDescriptionTable.COSTDESC18_FLD].ToString().Trim();
				objObject.CostDesc19 = odrPCS[ITM_CostDescriptionTable.COSTDESC19_FLD].ToString().Trim();
				objObject.CostDesc20 = odrPCS[ITM_CostDescriptionTable.COSTDESC20_FLD].ToString().Trim();
				objObject.CostDesc21 = odrPCS[ITM_CostDescriptionTable.COSTDESC21_FLD].ToString().Trim();
				objObject.MachRunHrsDesc = odrPCS[ITM_CostDescriptionTable.MACHRUNHRSDESC_FLD].ToString().Trim();
				objObject.MachSetupHrsDesc = odrPCS[ITM_CostDescriptionTable.MACHSETUPHRSDESC_FLD].ToString().Trim();
				objObject.LaborRunHrsDesc = odrPCS[ITM_CostDescriptionTable.LABORRUNHRSDESC_FLD].ToString().Trim();
				objObject.LaborSetupHrsDesc = odrPCS[ITM_CostDescriptionTable.LABORSETUPHRSDESC_FLD].ToString().Trim();
				objObject.CCNID = int.Parse(odrPCS[ITM_CostDescriptionTable.CCNID_FLD].ToString().Trim());

				}		
				return objObject;					
			}
			catch(OleDbException ex)
			{			
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			

			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}

		//**************************************************************************              
		///    <Description>
		///       This method uses to get data from ITM_CostDescription
		///    </Description>
		///    <Inputs>
		///        ID       
		///    </Inputs>
		///    <Outputs>
		///       ITM_CostDescriptionVO
		///    </Outputs>
		///    <Returns>
		///       ITM_CostDescriptionVO
		///    </Returns>
		///    <Authors>
		///       sonht
		///    </Authors>
		///    <History>
		///       Wednesday, January 19, 2005
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************

		public object GetObjectVO(string pstrCCNID)
		{
			const string METHOD_NAME = THIS + ".GetObjectVO()";
			
			OleDbDataReader odrPCS = null;
			OleDbConnection oconPCS = null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = String.Empty;
				strSql=	"SELECT "
					+ ITM_CostDescriptionTable.COSTDESCRIPTIONID_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC01_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC02_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC03_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC04_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC05_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC06_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC07_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC08_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC09_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC10_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC11_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC12_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC13_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC14_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC15_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC16_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC17_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC18_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC19_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC20_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC21_FLD + ","
					+ ITM_CostDescriptionTable.MACHRUNHRSDESC_FLD + ","
					+ ITM_CostDescriptionTable.MACHSETUPHRSDESC_FLD + ","
					+ ITM_CostDescriptionTable.LABORRUNHRSDESC_FLD + ","
					+ ITM_CostDescriptionTable.LABORSETUPHRSDESC_FLD + ","
					+ ITM_CostDescriptionTable.CCNID_FLD
					+ " FROM " + ITM_CostDescriptionTable.TABLE_NAME
					+" WHERE " + ITM_CostDescriptionTable.CCNID_FLD + "= " + pstrCCNID ;

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);

				ocmdPCS.Connection.Open();
				odrPCS = ocmdPCS.ExecuteReader();

				ITM_CostDescriptionVO objObject = new ITM_CostDescriptionVO();
				objObject.CostDescriptionID = 0; // not found

				while (odrPCS.Read())
				{ 
					objObject.CostDescriptionID = int.Parse(odrPCS[ITM_CostDescriptionTable.COSTDESCRIPTIONID_FLD].ToString().Trim());
					objObject.CostDesc01 = odrPCS[ITM_CostDescriptionTable.COSTDESC01_FLD].ToString().Trim();
					objObject.CostDesc02 = odrPCS[ITM_CostDescriptionTable.COSTDESC02_FLD].ToString().Trim();
					objObject.CostDesc03 = odrPCS[ITM_CostDescriptionTable.COSTDESC03_FLD].ToString().Trim();
					objObject.CostDesc04 = odrPCS[ITM_CostDescriptionTable.COSTDESC04_FLD].ToString().Trim();
					objObject.CostDesc05 = odrPCS[ITM_CostDescriptionTable.COSTDESC05_FLD].ToString().Trim();
					objObject.CostDesc06 = odrPCS[ITM_CostDescriptionTable.COSTDESC06_FLD].ToString().Trim();
					objObject.CostDesc07 = odrPCS[ITM_CostDescriptionTable.COSTDESC07_FLD].ToString().Trim();
					objObject.CostDesc08 = odrPCS[ITM_CostDescriptionTable.COSTDESC08_FLD].ToString().Trim();
					objObject.CostDesc09 = odrPCS[ITM_CostDescriptionTable.COSTDESC09_FLD].ToString().Trim();
					objObject.CostDesc10 = odrPCS[ITM_CostDescriptionTable.COSTDESC10_FLD].ToString().Trim();
					objObject.CostDesc11 = odrPCS[ITM_CostDescriptionTable.COSTDESC11_FLD].ToString().Trim();
					objObject.CostDesc12 = odrPCS[ITM_CostDescriptionTable.COSTDESC12_FLD].ToString().Trim();
					objObject.CostDesc13 = odrPCS[ITM_CostDescriptionTable.COSTDESC13_FLD].ToString().Trim();
					objObject.CostDesc14 = odrPCS[ITM_CostDescriptionTable.COSTDESC14_FLD].ToString().Trim();
					objObject.CostDesc15 = odrPCS[ITM_CostDescriptionTable.COSTDESC15_FLD].ToString().Trim();
					objObject.CostDesc16 = odrPCS[ITM_CostDescriptionTable.COSTDESC16_FLD].ToString().Trim();
					objObject.CostDesc17 = odrPCS[ITM_CostDescriptionTable.COSTDESC17_FLD].ToString().Trim();
					objObject.CostDesc18 = odrPCS[ITM_CostDescriptionTable.COSTDESC18_FLD].ToString().Trim();
					objObject.CostDesc19 = odrPCS[ITM_CostDescriptionTable.COSTDESC19_FLD].ToString().Trim();
					objObject.CostDesc20 = odrPCS[ITM_CostDescriptionTable.COSTDESC20_FLD].ToString().Trim();
					objObject.CostDesc21 = odrPCS[ITM_CostDescriptionTable.COSTDESC21_FLD].ToString().Trim();
					objObject.MachRunHrsDesc = odrPCS[ITM_CostDescriptionTable.MACHRUNHRSDESC_FLD].ToString().Trim();
					objObject.MachSetupHrsDesc = odrPCS[ITM_CostDescriptionTable.MACHSETUPHRSDESC_FLD].ToString().Trim();
					objObject.LaborRunHrsDesc = odrPCS[ITM_CostDescriptionTable.LABORRUNHRSDESC_FLD].ToString().Trim();
					objObject.LaborSetupHrsDesc = odrPCS[ITM_CostDescriptionTable.LABORSETUPHRSDESC_FLD].ToString().Trim();
					if(odrPCS[ITM_CostDescriptionTable.CCNID_FLD].ToString().Trim().Length > 0)
					{
						objObject.CCNID = int.Parse(odrPCS[ITM_CostDescriptionTable.CCNID_FLD].ToString().Trim());
					}
				}		
				return objObject;					
			}
			catch(OleDbException ex)
			{			
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			

			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}

		//**************************************************************************              
		///    <Description>
		///       This method uses to update data to ITM_CostDescription
		///    </Description>
		///    <Inputs>
		///       ITM_CostDescriptionVO       
		///    </Inputs>
		///    <Outputs>
		///       
		///    </Outputs>
		///    <Returns>
		///       
		///    </Returns>
		///    <Authors>
		///       HungLa
		///    </Authors>
		///    <History>
		///       09-Dec-2004
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************
		
	
		public void Update(object pobjObjecVO)
		{
			const string METHOD_NAME = THIS + ".Update()";

			ITM_CostDescriptionVO objObject = (ITM_CostDescriptionVO) pobjObjecVO;
			

			//prepare value for parameters
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = String.Empty;
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);
				strSql=	"UPDATE ITM_CostDescription SET "
				+ ITM_CostDescriptionTable.COSTDESC01_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC02_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC03_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC04_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC05_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC06_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC07_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC08_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC09_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC10_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC11_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC12_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC13_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC14_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC15_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC16_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC17_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC18_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC19_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC20_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.COSTDESC21_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.MACHRUNHRSDESC_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.MACHSETUPHRSDESC_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.LABORRUNHRSDESC_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.LABORSETUPHRSDESC_FLD + "=   ?" + ","
				+ ITM_CostDescriptionTable.CCNID_FLD + "=  ?"
				+" WHERE " + ITM_CostDescriptionTable.COSTDESCRIPTIONID_FLD + "= ?";

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC01_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC01_FLD].Value = objObject.CostDesc01;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC02_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC02_FLD].Value = objObject.CostDesc02;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC03_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC03_FLD].Value = objObject.CostDesc03;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC04_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC04_FLD].Value = objObject.CostDesc04;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC05_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC05_FLD].Value = objObject.CostDesc05;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC06_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC06_FLD].Value = objObject.CostDesc06;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC07_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC07_FLD].Value = objObject.CostDesc07;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC08_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC08_FLD].Value = objObject.CostDesc08;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC09_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC09_FLD].Value = objObject.CostDesc09;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC10_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC10_FLD].Value = objObject.CostDesc10;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC11_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC11_FLD].Value = objObject.CostDesc11;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC12_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC12_FLD].Value = objObject.CostDesc12;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC13_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC13_FLD].Value = objObject.CostDesc13;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC14_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC14_FLD].Value = objObject.CostDesc14;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC15_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC15_FLD].Value = objObject.CostDesc15;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC16_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC16_FLD].Value = objObject.CostDesc16;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC17_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC17_FLD].Value = objObject.CostDesc17;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC18_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC18_FLD].Value = objObject.CostDesc18;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC19_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC19_FLD].Value = objObject.CostDesc19;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC20_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC20_FLD].Value = objObject.CostDesc20;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESC21_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESC21_FLD].Value = objObject.CostDesc21;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.MACHRUNHRSDESC_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.MACHRUNHRSDESC_FLD].Value = objObject.MachRunHrsDesc;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.MACHSETUPHRSDESC_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.MACHSETUPHRSDESC_FLD].Value = objObject.MachSetupHrsDesc;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.LABORRUNHRSDESC_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.LABORRUNHRSDESC_FLD].Value = objObject.LaborRunHrsDesc;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.LABORSETUPHRSDESC_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.LABORSETUPHRSDESC_FLD].Value = objObject.LaborSetupHrsDesc;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.CCNID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.CCNID_FLD].Value = objObject.CCNID;

				ocmdPCS.Parameters.Add(new OleDbParameter(ITM_CostDescriptionTable.COSTDESCRIPTIONID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[ITM_CostDescriptionTable.COSTDESCRIPTIONID_FLD].Value = objObject.CostDescriptionID;


				ocmdPCS.CommandText = strSql;
				ocmdPCS.Connection.Open();
				ocmdPCS.ExecuteNonQuery();	
			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}

		}


		//**************************************************************************              
		///    <Description>
		///       This method uses to get all data from ITM_CostDescription
		///    </Description>
		///    <Inputs>
		///               
		///    </Inputs>
		///    <Outputs>
		///       DataSet
		///    </Outputs>
		///    <Returns>
		///       DataSet
		///    </Returns>
		///    <Authors>
		///       HungLa
		///    </Authors>
		///    <History>
		///       Wednesday, March 16, 2005
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************

		public DataSet List()
		{
			const string METHOD_NAME = THIS + ".List()";
			DataSet dstPCS = new DataSet();
			
		

			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = String.Empty;
				
				strSql=	"SELECT "
				+ ITM_CostDescriptionTable.COSTDESCRIPTIONID_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC01_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC02_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC03_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC04_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC05_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC06_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC07_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC08_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC09_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC10_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC11_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC12_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC13_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC14_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC15_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC16_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC17_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC18_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC19_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC20_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC21_FLD + ","
				+ ITM_CostDescriptionTable.MACHRUNHRSDESC_FLD + ","
				+ ITM_CostDescriptionTable.MACHSETUPHRSDESC_FLD + ","
				+ ITM_CostDescriptionTable.LABORRUNHRSDESC_FLD + ","
				+ ITM_CostDescriptionTable.LABORSETUPHRSDESC_FLD + ","
				+ ITM_CostDescriptionTable.CCNID_FLD
					+ " FROM " + ITM_CostDescriptionTable.TABLE_NAME;
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);
				ocmdPCS.Connection.Open();
				
				OleDbDataAdapter odadPCS = new OleDbDataAdapter(ocmdPCS);
				odadPCS.Fill(dstPCS,ITM_CostDescriptionTable.TABLE_NAME);

				return dstPCS;
			}
			catch(OleDbException ex)
			{
   				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}


		}


		//**************************************************************************              
		///    <Description>
		///       This method uses to get all data from ITM_CostDescription
		///    </Description>
		///    <Inputs>
		///               
		///    </Inputs>
		///    <Outputs>
		///       DataSet
		///    </Outputs>
		///    <Returns>
		///       DataSet
		///    </Returns>
		///    <Authors>
		///       HungLa
		///    </Authors>
		///    <History>
		///       Wednesday, March 16, 2005
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************

		public DataTable GetCostDescription(int pintCCNID)
		{
			const string METHOD_NAME = THIS + ".GetCostDescription()";
			DataSet dstPCS = new DataSet();
			
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = String.Empty;
				
				strSql=	"SELECT "
					+ ITM_CostDescriptionTable.COSTDESCRIPTIONID_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC01_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC02_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC03_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC04_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC05_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC06_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC07_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC08_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC09_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC10_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC11_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC12_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC13_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC14_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC15_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC16_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC17_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC18_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC19_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC20_FLD + ","
					+ ITM_CostDescriptionTable.COSTDESC21_FLD + ","
					+ ITM_CostDescriptionTable.MACHRUNHRSDESC_FLD + ","
					+ ITM_CostDescriptionTable.MACHSETUPHRSDESC_FLD + ","
					+ ITM_CostDescriptionTable.LABORRUNHRSDESC_FLD + ","
					+ ITM_CostDescriptionTable.LABORSETUPHRSDESC_FLD + ","
					+ ITM_CostDescriptionTable.CCNID_FLD
					+ " FROM " + ITM_CostDescriptionTable.TABLE_NAME
					+ " WHERE " + ITM_CostDescriptionTable.CCNID_FLD + "=" + pintCCNID;

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);
				ocmdPCS.Connection.Open();
				
				OleDbDataAdapter odadPCS = new OleDbDataAdapter(ocmdPCS);
				odadPCS.Fill(dstPCS,ITM_CostDescriptionTable.TABLE_NAME);

				return dstPCS.Tables[0];
			}
			catch(OleDbException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}


		}


		//**************************************************************************              
		///    <Description>
		///       This method uses to get all data from ITM_CostDescription
		///    </Description>
		///    <Inputs>
		///               
		///    </Inputs>
		///    <Outputs>
		///       DataSet
		///    </Outputs>
		///    <Returns>
		///       DataSet
		///    </Returns>
		///    <Authors>
		///       HungLa
		///    </Authors>
		///    <History>
		///       Wednesday, March 16, 2005
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************

		public DataTable GetHourCostDescription(int pintCCNID)
		{
			const string METHOD_NAME = THIS + ".GetHourCostDescription()";
			DataSet dstPCS = new DataSet();
			
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = String.Empty;
				
				strSql=	"SELECT "
					+ ITM_CostDescriptionTable.MACHRUNHRSDESC_FLD + ","
					+ ITM_CostDescriptionTable.MACHSETUPHRSDESC_FLD + ","
					+ ITM_CostDescriptionTable.LABORRUNHRSDESC_FLD + ","
					+ ITM_CostDescriptionTable.LABORSETUPHRSDESC_FLD
					+ " FROM " + ITM_CostDescriptionTable.TABLE_NAME
					+ " WHERE " + ITM_CostDescriptionTable.CCNID_FLD + "=" + pintCCNID;

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);
				ocmdPCS.Connection.Open();
				
				OleDbDataAdapter odadPCS = new OleDbDataAdapter(ocmdPCS);
				odadPCS.Fill(dstPCS,ITM_CostDescriptionTable.TABLE_NAME);

				return dstPCS.Tables[0];
			}
			catch(OleDbException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}


		}


		//**************************************************************************              
		///    <Description>
		///       This method uses to update a DataSet
		///    </Description>
		///    <Inputs>
		///        DataSet       
		///    </Inputs>
		///    <Outputs>
		///       
		///    </Outputs>
		///    <Returns>
		///       
		///    </Returns>
		///    <Authors>
		///       HungLa
		///    </Authors>
		///    <History>
		///       Wednesday, March 16, 2005
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************
		
		public void UpdateDataSet(DataSet pData)
		{
			const string METHOD_NAME = THIS + ".UpdateDataSet()";
			string strSql;
			OleDbConnection oconPCS =null;
			OleDbCommandBuilder odcbPCS ;
			OleDbDataAdapter odadPCS = new OleDbDataAdapter();

			try
			{
				strSql=	"SELECT "
				+ ITM_CostDescriptionTable.COSTDESCRIPTIONID_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC01_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC02_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC03_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC04_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC05_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC06_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC07_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC08_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC09_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC10_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC11_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC12_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC13_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC14_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC15_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC16_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC17_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC18_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC19_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC20_FLD + ","
				+ ITM_CostDescriptionTable.COSTDESC21_FLD + ","
				+ ITM_CostDescriptionTable.MACHRUNHRSDESC_FLD + ","
				+ ITM_CostDescriptionTable.MACHSETUPHRSDESC_FLD + ","
				+ ITM_CostDescriptionTable.LABORRUNHRSDESC_FLD + ","
				+ ITM_CostDescriptionTable.LABORSETUPHRSDESC_FLD + ","
				+ ITM_CostDescriptionTable.CCNID_FLD 
		+ "  FROM " + ITM_CostDescriptionTable.TABLE_NAME;

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				odadPCS.SelectCommand = new OleDbCommand(strSql, oconPCS);
				odcbPCS = new OleDbCommandBuilder(odadPCS);
				pData.EnforceConstraints = false;
				odadPCS.Update(pData,ITM_CostDescriptionTable.TABLE_NAME);

			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else if (ex.Errors[1].NativeError == ErrorCode.SQLCASCADE_PREVENT_KEYCODE)
				{

					throw new PCSDBException(ErrorCode.CASCADE_DELETE_PREVENT, METHOD_NAME, ex);				
				}
				
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}

		}
	}
}
